﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using NorthwindDataservice;

namespace NorthwindWebservice.Controllers
{
    [Route("api/products")]
    public class ProductsController : Controller
    {
        DataService _dataService;

        //Dependency Injection
        public ProductsController(DataService dataService)
        {
            _dataService = dataService;
        }

        [HttpGet("name/{name}")]
        public IActionResult ListProducts(string name)
        {
            var products = _dataService.GetProductByName(name);
            return Ok(products);
        }

        public IActionResult Index()
        {
            return Ok();
        }
    }
}